package com.gopay.common.cps.dao.ic.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.ic.NextDayOrderDAO;
import com.gopay.common.domain.ic.NextDayOrder;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 切日订单记录Dao实现
 * @Author jianghoupeng
 * @Date 2017/1/16 11:10
 *
 * Copyright (c) 2017. www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("nextDayOrderDAO")
public class NextDayOrderDAOImpl extends BaseDAOImpl<NextDayOrder, String> implements NextDayOrderDAO {

    @Override
    public NextDayOrder queryOrderBycheckDateAndId(Map param) {
        StringBuilder hql = new StringBuilder();
        Map map = new HashMap<>();
        map.put("checkDate", param.get("checkDate"));
        map.put("gopayOrderId", param.get("gopayOrderId"));
        hql.append(" from NextDayOrder where checkDate =:checkDate and gopayOrderId=:gopayOrderId");
        List<NextDayOrder> list = this.findByHql(hql.toString(), map);
        if (list != null && list.size() == 1){
            return list.get(0);
        }
        return null;
    }
}
